#include <stdio.h>
#include <string.h>

int is_valid_ip(char* ip)
{
    int num, dots = 0;
    char* token = strtok(ip, ".");

    while (token != NULL)
    {
        num = atoi(token);
        if (num < 0 || num > 255)
        {
            return 0;
        }
        token = strtok(NULL, ".");
        dots++;
    }

    return dots == 4;
}

int main()
{
    int n, count = 0;
    char ip[20];

    scanf("%d", &n);

    for (int i = 0; i < n; i++)
    {
        scanf("%s", ip);
        if (is_valid_ip(ip))
        {
            count++;
        }
    }

    printf("%d\n", count);

    return 0;
}
